package day07;

import java.util.Scanner;

/**
 * 说明:
 *
 * @author: luohaowei
 * @date:2023/2/20
 **/
public class kabudo {
    public static void main(String[] args) {
        double[] scores=kabudo();
        double avg=calAvg(scores);
        System.out.println("平均分为:"+avg);
    }
    public static double[] kabudo(){
        Scanner scan=new Scanner(System.in);
        double[] scores=new double[6];
        for(int i=0;i<scores.length;i++){
            System.out.println("请录入第"+(i+1)+"个评委的分数");
            scores[i]=scan.nextDouble();
        }
        return scores;
        }
    public static double calAvg(double[] scores){
        double total=kabudo(scores);
        double avg=total/(scores.length-2);
        return avg;
    }
    public static  double kabudo(double[] score) {
        double total = 0.0;
        double max = score[0];
        double min = score[0];
        for (int i = 0; i < score.length; i++) {
            if (score[i] > max) {
                max = score[i];
            }
            if (score[i] < min) {
                min = score[i];
            }
            total += score[i];
            return total;
        }
        return total - max - min;
    }

    /*
    public static void main(String[] args) {
        double[] scores=kabudo();
        double avg=calAvg(scores);
        System.out.println("平均分为:"+avg);
    }
    public static double[] kabudo(){
        Scanner scan=new Scanner(System.in);
        double[] scores=new double[6];
        for(int i=0;i<scores.length;i++){
            System.out.println("请录入第"+(i+1)+"个评委的分数");
            scores[i]=scan.nextDouble();
        }
        return scores;
        }
    public static double calAvg(double[] scores){
        double total=kabudo(scores);
        double avg=total/(scores.length-2);
        return avg;
    }
    public static  double kabudo(double[] score) {
        double total = 0.0;
        double max = score[0];
        double min = score[0];
        for (int i = 0; i < score.length; i++) {
            if (score[i] > max) {
                max = score[i];
            }
            if (score[i] < min) {
                min = score[i];
            }
            total += score[i];
            return total;
        }
        return total - max - min;
    }
     */
}
